package com.spring.bucks.exception;

import com.spring.bucks.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

/**
 * @author 超
 * Create by fengc on  2022/8/20 17:14
 * 简单自定义异常跑出
 */
@Slf4j
@ControllerAdvice
public class ExceptionConfig {

    @ExceptionHandler(value = BusinessException.class)
    @ResponseBody
    public Object handleGlobalException(BusinessException ex) {
        return Result.fail(ex.getLocalizedMessage());
    }
}
